package day11;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String str = in.nextLine();
            Stack<Character> stack1 = new Stack<>();
            Stack<Character> stack2 = new Stack<>();
            for(int i = 0; i < str.length(); i++) {
                stack1.push(str.charAt(i));
            }
            StringBuilder ret = new StringBuilder();
            for(int i = 0; i < str.length(); i++) {
                if(stack1.isEmpty()) {
                    break;
                }
                if(stack1.peek() != ' ' && stack1.isEmpty() == false) {
                    stack2.push(stack1.pop());
                }else if(stack1.peek() == ' ' && stack1.isEmpty() == false) {
                    int size = stack2.size();
                    for(int j = 0; j < size; j++) {
                        ret.append(stack2.pop());
                    }
                    ret.append(stack1.pop());
                }
            }
            System.out.println(ret);
        }
    }
}
